/**
 * 
 * @param {string} type 成功success，失败 fail，加载中 loading ，询问 ask，提示 none
 * @param {string} msg
 * @param {function} determine
 * @param {function} detecancel
 * @param {boolean} sc
 */
const tip = (  msg,type = "none", determine = null, detecancel = null, sc = true,askTitle='提示',confirmText='确定',cancelText='取消') => {
	if (determine == null) {
		determine = () => {}
	}
	if (detecancel == null) {
		detecancel = () => {}
	}
	setTimeout(() => {
		if (type == 'success') {
			uni.showToast({
				title: msg,
				icon: 'success',
				duration: 2000,
				mask: true,
			})
		} else if (type == 'fail') {
			uni.showToast({
		 	title: msg,
				icon: 'error',
				duration: 2000,
				mask: true,
			})
		} else if (type == 'loading') {
			uni.showLoading({
				title: msg,
				mask: true,
			})
		} else if (type == 'ask') {
			uni.showModal({
				title:askTitle,
				content: msg,
				showCancel: sc,
				cancelText:cancelText,
				confirmText:confirmText,
				confirmColor: '#4A8AE9',
				success: function(res) {
					if (res.confirm) {
						determine()
					} else {
						detecancel()
					}
				}
			})
		} else if (type == 'none') {
			uni.showToast({
				title: msg,
				icon: 'none',
				duration: 2000,
				mask: true,
			})
		}
	}, 100)
}

export default tip
